﻿@model mvcForum.Web.ViewModels.MessageViewModel
@using CreativeMinds.MVC.Common.Helpers;
@using mvcForum.Web.Extensions;
@using mvcForum.Web.Helpers;
@{
	var postFix = String.Empty;
	if (Model.Position == 1) {
		postFix = "-first";
	}

	var id = Model.Id.ToString();
	var position = Model.Position.ToString();
}
<!-- Areas/Forum/Views/Shared/MessagePartial.cshtml -->
<div id="p@(id)" class="post">
	<div class="block-header"><span><span></span></span></div>
	<div class="block-content block-post block-post@(postFix)">
		<div class="block-inner">
			<!--<div id="maximize0" class="post-maximize" style="display: none;"><a href="javascript:void(0);" onclick="ca_post_maximize_all(); return false;"><span>&gt;&gt;</span></a></div>-->
			<div id="profilediv@(position)">
				<div class="profile-block">
				@Html.Partial("MessagePosterPartial", Model)
				</div>
			</div>
			<div class="postbody" id="body@(position)">
				<div class="post-content">
					<p class="author">
						<a href="#p@(position)">
							<img src="@Url.ForumImage("icon_post_target.gif")" width="11" height="9" alt="Post" title="Post" /></a>
						@Model.Posted.ToLocalDateTime().ToString("F")
					</p>
					<h3 @if (Model.Position == 1) { <text>class="first"</text> }>
						<a href="#p@(id)">@Model.Subject</a></h3>
					<div class="content">
						@Html.BBCodeToHtml(Model.Body)
					</div>
@if (Model.Attachments.Count > 0) {
					<div class="ca-bbcode">
						<div class="ca-bbcode2 ca-attachment">
							<dl class="attachbox">
								<dt>@ForumHelper.GetString("ViewMessage.Attachments")</dt>
	@foreach (var att in Model.Attachments) {
@*	if (att.IsImage) {
									<dd>@Html.Image(att.Path + att.Filename, att.Filename, new Dictionary<String, String>())</dd>
	}
	else {*@
									<dd>@Html.AttachmentLink(att)</dd>
	}
 }
							</dl>
						</div>
					</div>
}
@if (Model.LastEdited.HasValue) {
						<div class="notice">
							@ForumHelper.GetString("ViewMessage.Edited", new { Editor = (Model.ModeratorChanged ? ForumHelper.GetString("Moderator") : Model.PrettyName), Timestamp = Model.LastEdited.Value.ToLocalDateTime() })
						</div>
}
					<!--<div class="signature" id="sig: Model.Id ">test</div>-->
				</div>
				<ul class="profile-icons">
					<li class="top-icon"><a href="#top" class="top" title="Top"><span>Top</span></a></li>
@if (Model.Authenticated) {
						<li class="report-icon"><a title="Report" href="@Url.Action("Report", "Message", new RouteValueDictionary { { "id", Model.Id } })">
							<span>@ForumHelper.GetString("ViewMessage.Report")</span></a> </li>
}
@if (Model.CanDelete) {
						<li class="delete-icon"><a title="Delete" href="@Url.Action("Delete", "Message", new RouteValueDictionary { { "id", Model.TopicId } })">
							<span>@ForumHelper.GetString("ViewMessage.Delete")</span></a> </li>
}
@if (Model.CanPost) {
						<li class="quote-icon"><a title="Quote" href="@Url.Action("Create", "Message", new RouteValueDictionary { { "id", Model.TopicId }, { "replytoid", Model.Id } })">
							<span>@ForumHelper.GetString("ViewMessage.Quote")</span></a> </li>
}
@if (Model.CanEdit) {
						<li class="edit-icon"><a title="Edit post" href="@Url.Action("Edit", "Message", new RouteValueDictionary { { "id", Model.Id } })">
							<span>@ForumHelper.GetString("ViewMessage.Edit")</span></a> </li>
}
				</ul>
				<div class="clear"></div>
			</div>
			<div class="block-clear"></div>
		</div>
	</div>
	<div class="block-footer"><span><span></span></span></div>
</div>
